import { enableRedirectResponseInterceptor, RedirectResponseInterceptor } from 'geminis-react';
import { RequestConfig } from '@umijs/max';

const PurchaseState = new Map([
  [10, '已计划'],
  [20, '已发货'],
  [30, '已到货'],
  [40, '已收货'],
  [50, '已验收'],
  [60, '已装箱'],
]);

const DeliveryState = new Map([
  [10, '已预约'],
  [20, '已装车'],
  [30, '已发货'],
]);

window.purchaseState = (value: number) => {
  return PurchaseState.get(value);
};

window.deliveryState = (value: number) => {
  return DeliveryState.get(value);
};

enableRedirectResponseInterceptor();

export const request: RequestConfig = {
  responseInterceptors: [[RedirectResponseInterceptor, RedirectResponseInterceptor]],
};